X-Git-Url: http://git.cyclocoop.org//%22http:/%22.attribut_html%28%24lesurls%5B%24numero%5D%29.%22/%22?a=blobdiff_plain;f=includes%2FLinker.php;h=f4131ed40fcb23ecd524a1f2fe431273d250e8d7;hb=f8cc99ea9885103ed4ee23b83efc003d24c98450;hp=6a869dd45f7bafe83acbcbcef85aed766d9c18a3;hpb=3302e11b23301ee55196b372c1cf5ff48a5ab6c3;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Linker.php b/includes/Linker.php index 6a869dd45f..f4131ed40f 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -269,7 +269,7 @@ class Linker { */ public static function linkKnown( $target, $html = null, $customAttribs = [], - $query = [], $options = [ 'known', 'noclasses' ] + $query = [], $options = [ 'known' ] ) { return self::link( $target, $html, $customAttribs, $query, $options ); } @@ -940,7 +940,15 @@ class Linker { $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title ); if ( $redir ) { - return self::linkKnown( $title, $encLabel, [], wfCgiToArray( $query ) ); + // We already know it's a redirect, so mark it + // accordingly + return self::link( + $title, + $encLabel, + [ 'class' => 'mw-redirect' ], + wfCgiToArray( $query ), + [ 'known', 'noclasses' ] + ); } $href = self::getUploadUrl( $title, $query ); @@ -950,7 +958,7 @@ class Linker { $encLabel . ''; } - return self::linkKnown( $title, $encLabel, [], wfCgiToArray( $query ) ); + return self::link( $title, $encLabel, [], wfCgiToArray( $query ), [ 'known', 'noclasses' ] ); } /** @@ -1084,7 +1092,16 @@ class Linker { if ( !$title ) { $title = $wgTitle; } - $attribs['rel'] = Parser::getExternalLinkRel( $url, $title ); + $newRel = Parser::getExternalLinkRel( $url, $title ); + if ( !isset( $attribs['rel'] ) || $attribs['rel'] === '' ) { + $attribs['rel'] = $newRel; + } elseif ( $newRel !== '' ) { + // Merge the rel attributes. + $newRels = explode( ' ', $newRel ); + $oldRels = explode( ' ', $attribs['rel'] ); + $combined = array_unique( array_merge( $newRels, $oldRels ) ); + $attribs['rel'] = implode( ' ', $combined ); + } $link = ''; $success = Hooks::run( 'LinkerMakeExternalLink', [ &$url, &$text, &$link, &$attribs, $linktype ] ); @@ -1872,7 +1889,9 @@ class Linker { * work if $wgShowRollbackEditCount is disabled, so this can only function * as an additional check. * - * If the option noBrackets is set the rollback link wont be enclosed in [] + * If the option noBrackets is set the rollback link wont be enclosed in "[]". + * + * See the "mediawiki.page.rollback" module for the client-side handling of this link. * * @since 1.16.3. $context added in 1.20. $options added in 1.21 * @@ -1902,6 +1921,8 @@ class Linker { $inner = $context->msg( 'brackets' )->rawParams( $inner )->escaped(); } + $context->getOutput()->addModules( 'mediawiki.page.rollback' ); + return '' . $inner . ''; } @@ -1996,11 +2017,13 @@ class Linker { $query = [ 'action' => 'rollback', 'from' => $rev->getUserText(), - 'token' => $context->getUser()->getEditToken( [ - $title->getPrefixedText(), - $rev->getUserText() - ] ), ]; + $attrs = [ + 'data-mw' => 'interface', + 'title' => $context->msg( 'tooltip-rollback' )->text(), + ]; + $options = [ 'known', 'noclasses' ]; + if ( $context->getRequest()->getBool( 'bot' ) ) { $query['bot'] = '1'; $query['hidediff'] = '1'; // bug 15999 @@ -2025,27 +2048,16 @@ class Linker { } if ( $editCount > $wgShowRollbackEditCount ) { - $editCount_output = $context->msg( 'rollbacklinkcount-morethan' ) + $html = $context->msg( 'rollbacklinkcount-morethan' ) ->numParams( $wgShowRollbackEditCount )->parse(); } else { - $editCount_output = $context->msg( 'rollbacklinkcount' )->numParams( $editCount )->parse(); + $html = $context->msg( 'rollbacklinkcount' )->numParams( $editCount )->parse(); } - return self::link( - $title, - $editCount_output, - [ 'title' => $context->msg( 'tooltip-rollback' )->text() ], - $query, - [ 'known', 'noclasses' ] - ); + return self::link( $title, $html, $attrs, $query, $options ); } else { - return self::link( - $title, - $context->msg( 'rollbacklink' )->escaped(), - [ 'title' => $context->msg( 'tooltip-rollback' )->text() ], - $query, - [ 'known', 'noclasses' ] - ); + $html = $context->msg( 'rollbacklink' )->escaped(); + return self::link( $title, $html, $attrs, $query, $options ); } }